package ru.xeden.web.html.dom;

import ru.xeden.web.html.RenderContext;

/**
 * Атрибут ноды
 * @author evga
 *
 */
public class Attribute
{
    private final String name;
    private String value;
    private Attribute nextAttribute;

    Attribute(String name, String value, Attribute nextAttribute)
    {
        this.name = name;
        this.value = value;
        this.nextAttribute = nextAttribute;
    }

    public String getName()
    {
        return name;
    }

    public String getValue()
    {
        return value;
    }

    public void setValue(String value)
    {
        this.value = value;
    }

    public Attribute getNextAttribute()
    {
        return nextAttribute;
    }
    
    public void setNextAttribute(Attribute nextAttribute)
    {
        this.nextAttribute = nextAttribute;;
    }
    
    public void render(RenderContext markupContext, StringBuilder builder)
    {
        MarkupModel model = markupContext.getMarkupModel();
        builder.append(" ");
        builder.append(name);
        builder.append("=");
        builder.append(model.getAttributeQuote());
        model.encodeQuoted(value, builder);
        builder.append(model.getAttributeQuote());
    }

    boolean matches(String name)
    {
        return this.name.equalsIgnoreCase(name);
    }
}
